home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-01-26 | 724 b | 25 lines | [TEXT/KEEN] |
- BEGIN { find = "(^|[^@])([A-Z][A-Z]+)"
- rep["CA"] = "California"
- rep["HYPO"] = "hypobetalipoproteinemia"
- rep["RE"] = "regular expression"
- #...etc...
- rep["SOM"] = "osoma"
- }
- {loopCount = 0;
- while (match($0, find) && loopCount++ < 50)
- {
- acronym= substr($0, RSTART, RLENGTH)
- sub(find, "\2", acronym)
- ##gsub(/[^A-Z@#]/, "", acronym)
- if (acronym in rep)
- sub(find, "\1" rep[acronym])#replace acronym by expansion
- else
- sub(find, "\1@#@\2")#stick '@#@' in front of unknown acronym
- }
- if (loopCount >= 50)
- {
- print "The acronym", acronym, "is looping forever." ; exit
- }
- gsub(/@#@/, "")#trim the protector by replacing it with null string
- print >> (STDPATH "junker")#print the altered line to stdout
- }